import urllib
from django.utils import simplejson 
#import simplejson

def get_list(base_url):
    urllist=[]
    alphabet_list=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
    for alphabet in alphabet_list:
        result = simplejson.load(urllib.urlopen('http://sandbox-freebase.com/api/service/mqlread?query={"query":[{"name":null,"id":null, "sort":"name","type":"/base/bioventurist/science_or_technology_company","sort":"name","name~=":"^'+alphabet+'*"}]}'))
        results=result['result']
        for item in results:
            full_url=base_url+'/company'+item['id']
            urllist.append(full_url)
    for alphabet in alphabet_list:
        result = simplejson.load(urllib.urlopen('http://www.freebase.com/api/service/mqlread?query={"query":[{"name":null,"id":null, "type":"/base/bioventurist/bv_medical_condition","sort":"name","name~=":"^'+alphabet+'*"}]}'))
        results=result['result']
        for item in results:
            full_url=base_url+'/disease'+item['id']
            urllist.append(full_url)
    for alphabet in alphabet_list:
        result = simplejson.load(urllib.urlopen('http://www.freebase.com/api/service/mqlread?query={"query":[{"name":null,"id":null, "type":"/user/bioventurist/default_domain/technology_class", "sort":"name","sort":"name","name~=":"^'+alphabet+'*"}]}'))
        results=result['result']
        for item in results:
            full_url=base_url+'/technology'+item['id']
            urllist.append(full_url)        
    return urllist
        
        
